package com.gafker.pool;

import java.util.Timer;
import java.util.TimerTask;
/**
 * TimerTask 单线程，单任务执行
 * @author gafker
 *
 */

public class TimerTest  extends TimerTask{
	
	private String jobName = ""; 
	 
	 public TimerTest(String jobName) { 
	 super(); 
	 this.jobName = jobName; 
	 } 
	public static void main(String[] args) {
		Timer timer =new Timer();
		long delay1 = 1*1000;
		long period1 = 1000;
		timer.schedule(new TimerTest("Gafker Running..."), delay1, period1);
		long delay2 = 2*1000;
		long period2 = 2000;
		timer.schedule(new TimerTest("Life is..... Running..."), delay2, period2);
	}

	@Override
	public void run() {
		// TODO Auto-generated method stub
		System.out.println("execute " + jobName); 
	}
}
